/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package verins.Utils;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.Iterator;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author hectdx
 */
public class Comunes {
 
    //recibe el list del query, y llena el combo con objetos
    //para q se muestre la descripcion del objeto, se debe reescribir el toString()
    public static void  llenarCombo(JComboBox combo,List lista){
      
        Iterator it =lista.iterator();
        while (it.hasNext()){
            combo.addItem(it.next());
        }
    }
    
    public static void centrarVentana(JFrame vent){
        Toolkit tk=vent.getToolkit();
        Dimension d=tk.getScreenSize();
        int x=(int)(d.getWidth()/2 -vent.getWidth()/2);
        int y=(int) (d.getHeight()/2 -vent.getHeight()/2);
        vent.setLocation(x,y );
    }
    
    public static void limpiarTabla(JTable tabla){
        DefaultTableModel dtm=(DefaultTableModel)tabla.getModel();
        while(dtm.getRowCount()>0)
            dtm.removeRow(0);
    }
    
}
